/* GUI CONVERTED from rprsrp2a.p (converter v1.75) Mon Oct 23 21:05:03 2000 */
/* rprsrp2a.p - RESOURCE LOAD DETAIL REPORT                             */
/* Copyright 1986-2002 QAD Inc., Carpinteria, CA, USA.                 */
/* All rights reserved worldwide.  This is an unpublished work.        */
/*F0PN*/ /*K1DJ*/
/*V8:ConvertMode=Report                                        */
/* REVISION: 1.0     LAST MODIFIED: 05/12/86    BY: pml                 */
/* REVISION: 1.0     LAST MODIFIED: 05/14/86    BY: emb                 */
/* REVISION: 1.0     LAST MODIFIED: 09/16/86    BY: emb *12*            */
/* REVISION: 2.0     LAST MODIFIED: 01/06/88    BY: pml *A125*          */
/* REVISION: 4.0     LAST MODIFIED: 02/24/88    BY: wug *A175*          */
/* REVISION: 4.0     LAST MODIFIED: 03/23/88    BY: rl  *A171*          */
/* REVISION: 4.0     LAST MODIFIED: 06/20/89    BY: emb *A748*          */
/* REVISION: 5.0     LAST MODIFIED: 06/20/89    BY: ftb *B422*          */
/* REVISION: 5.0     LAST MODIFIED: 02/22/90    BY: wug *B582*          */
/* REVISION: 4.0     LAST MODIFIED: 02/22/90    BY: wug *B583*          */
/* REVISION: 5.0     LAST MODIFIED: 04/04/90    BY: ram *B640*          */
/* REVISION: 6.0     LAST MODIFIED: 04/10/90    BY: ram *D018*          */
/* REVISION: 5.0     LAST MODIFIED: 06/08/90    BY: ram *B705*          */
/* REVISION: 5.0     LAST MODIFIED: 09/27/90    BY: ram *B793*          */
/* REVISION: 7.0     LAST MODIFIED: 10/11/91    BY: emb *F024*          */
/* REVISION: 7.3     LAST MODIFIED: 10/23/92    BY: ram *G231*          */
/* REVISION: 7.3     LAST MODIFIED: 10/17/95    BY: qzl *G0ZB*          */
/* REVISION: 8.6     LAST MODIFIED: 12/11/97    BY: bvm *K1DJ*          */

/* REVISION: 8.6E     LAST MODIFIED: 02/23/98   BY: *L007* A. Rahane */
/* REVISION: 8.6E     LAST MODIFIED: 10/04/98   BY: *J314* Alfred Tan   */
/* REVISION: 9.1      LAST MODIFIED: 08/11/00   BY: *N0K5* Arul Victoria   */
/* REVISION: 9.1      LAST MODIFIED: 10/23/00   BY: *N0T0* Katie Hilbert    */

/*GUI preprocessor directive settings */
&SCOPED-DEFINE PP_GUI_CONVERT_MODE REPORT

     {mfdeclre.i}
/*N0K5*/ {gplabel.i}

/* ********** Begin Translatable Strings Definitions ********* */

/*N0T0***BEGIN DELETE
 * &SCOPED-DEFINE rprsrp2a_p_6 "Day/Week/Month"
 * /* MaxLen: Comment: */
 *N0T0***END DELETE*/

&SCOPED-DEFINE rprsrp2a_p_4 "Output"
/* MaxLen: Comment: */

&SCOPED-DEFINE rprsrp2a_p_10 "Per Column"
/* MaxLen: Comment: */

/* ********** End Translatable Strings Definitions ********* */

/*N0K5* ------------------- BEGIN DELETE ----------------------- *
 * &SCOPED-DEFINE rprsrp2a_p_1 "Workdays      "
 * /* MaxLen: Comment: */
 *
 * &SCOPED-DEFINE rprsrp2a_p_2 "Total Load    "
 * /* MaxLen: Comment: */
 *
 * &SCOPED-DEFINE rprsrp2a_p_3 "Cumulative    "
 * /* MaxLen: Comment: */
 *
 * &SCOPED-DEFINE rprsrp2a_p_5 "Capacity      "
 * /* MaxLen: Comment: */
 *
 * &SCOPED-DEFINE rprsrp2a_p_7 "Over/Under    "
 * /* MaxLen: Comment: */
 *
 * &SCOPED-DEFINE rprsrp2a_p_8 "Item Number: "
 * /* MaxLen: Comment: */
 *
 * &SCOPED-DEFINE rprsrp2a_p_9 "Past    "
 * /* MaxLen: Comment: */
 *
 * &SCOPED-DEFINE rprsrp2a_p_11 " W/O:"
 * /* MaxLen: Comment: */
 *
 *N0K5* ------------------- END   DELETE ----------------------- */

/*K1DJ*/ {wbrp02.i}

     define shared variable start like rq_start.
     define variable rscde like rq_rsc no-undo.
     define variable interval as integer extent 13 no-undo.
     define variable sdate like ro_start extent 13 no-undo.
     define variable load as decimal extent 13 format "->>>,>>9" no-undo.
     define variable cap as decimal extent 13 format "->>>,>>9" no-undo.
     define variable ovund as decimal extent 13 format "->>>,>>9" no-undo.
     define variable cum as decimal extent 13 format "->>>,>>9" no-undo.
     define variable workdays as integer extent 13 format ">>>>,>>9" no-undo.
     define variable det_load as decimal extent 13 format "->>>,>>9" no-undo.
     define variable i as integer no-undo.
     define variable j as integer no-undo.
     define variable qty like rq_qty no-undo.
     define variable nonwdays as decimal no-undo.
     define variable elapsedays as integer no-undo.
     define variable wdays as integer no-undo.
     define variable overlap as integer no-undo.
     define variable wointerval as integer no-undo.
     define variable ltoffperiod as integer no-undo.
     define variable lead as integer no-undo.
     define variable num_intervals as integer initial 12 no-undo.
/*N0T0*     define shared variable dwm as character format "!"  */
/*N0T0*        label {&rprsrp2a_p_6}.                           */
/*N0T0*/define shared variable dwm as character.
     define shared variable idays as integer format ">>>>>9"
        label {&rprsrp2a_p_10}.
     define variable monthend as integer no-undo.
     define variable desc1 like pt_desc1 no-undo.
     define shared variable rsc like rs_rsc.
     define shared variable rsc1 like rs_rsc.
     define shared variable dev as character format "x(8)" label {&rprsrp2a_p_4}.

     define shared variable site like rs_site.
     define shared variable site1 like rs_site.

     for each rs_mstr no-lock where (rs_rsc >= rsc and rs_rsc <= rsc1)
     and rs_site >= site and rs_site <= site1:

        /* COMPUTE START DATES */
        sdate[1] = today.
        {mfcsdate.i}

        do i = 1 to num_intervals + 1:
           sdate[i] = max(sdate[i],today).
           if i > 1 then interval[i - 1] = max(sdate[i] - sdate[i - 1],0).
        end.

        /* INITIALIZE VARIABLES */
        assign
           workdays = 0
           cap = 0
           load = 0
           ovund = 0
           cum = 0.

        /* CALCULATE WORKING DAYS IN EACH INTERVAL */
        {mfcwdays.i rs_site}

        /* CALCULATE CAPACITY IN EACH INTERVAL */
        rscde = rs_rsc.
/*G231      {mfccap.i} */
/*G231*/    {mfccap.i rs_site}

        {mfcsdate.i}
        {mfcwdays.i rs_site}
        workdays[1] = max(workdays[1],0).
        sdate[1] = low_date.

        page.

        display rs_rsc rs_desc no-label rs_um space(6) rs_site
        with
/*N0K5*/   frame c
        width 132 side-labels STREAM-IO /*GUI*/ .

/*N0K5* ------------------- BEGIN ADD ----------------------- */
           /* SET EXTERNAL LABELS */
           setFrameLabels(frame c:handle).
/*N0K5* ------------------- END   ADD ----------------------- */

/*N0K5* ------------------- BEGIN DELETE ----------------------- *
 *      display space(23) {&rprsrp2a_p_9} sdate[2 for 11] skip
 *      with frame b no-labels width 132.
 *N0K5* ------------------- END   DELETE ----------------------- */

/*N0K5* ------------------- BEGIN ADD ----------------------- */
        display space(23)
         getTermLabel("PAST",8) sdate[2 for 11] skip
        with frame b no-labels width 132 STREAM-IO /*GUI*/ .
/*N0K5* ------------------- END   ADD ----------------------- */

        display space(23)
        sdate[2] - 1 sdate[3] - 1 sdate[4] - 1 sdate[5] - 1
        sdate[6] - 1 sdate[7] - 1 sdate[8] - 1 sdate[9] - 1
        sdate[10] - 1 sdate[11] - 1 sdate[12] - 1 sdate[13] - 1
        skip space(23)
        "-------- -------- -------- -------- -------- -------- --------"
        "-------- -------- -------- -------- --------"
        with frame b no-labels width 132 page-top STREAM-IO /*GUI*/ .

/*N0K5* ------------------- BEGIN DELETE ----------------------- *
 *      display {&rprsrp2a_p_1} space(9) workdays[1 for 12] skip
 *      {&rprsrp2a_p_5} space(9) cap[1 for 12]
 *      with frame e no-labels width 132.
 *N0K5* ------------------- END   DELETE ----------------------- */

/*N0K5* ------------------- BEGIN ADD ----------------------- */
        display
         getTermLabel("WORKDAYS",14) format "x(14)"
         space(9) workdays[1 for 12] skip
         getTermLabel("CAPACITY",14) format "x(14)"
         space(9) cap[1 for 12]
        with frame e no-labels width 132 STREAM-IO /*GUI*/ .
/*N0K5* ------------------- END   ADD ----------------------- */

        find shop_cal no-lock where shop_site = rs_site
        and shop_wkctr = "" and shop_mch = "" no-error.
        if not available shop_cal then
        find shop_cal no-lock where shop_site = ""
        and shop_wkctr = "" and shop_mch = "" no-error.

        if available shop_cal then do:
           rscde = rs_rsc.
           for each rq_mstr where rq_rsc = rscde
           and rq_site = rs_site
           no-lock break by rq_site by rq_part:

          if first-of (rq_part) then do:

/*N0K5*      desc1 = {&rprsrp2a_p_8} + rq_part. */
/*N0K5*/     desc1 = getTermLabel("ITEM_NUMBER",11) + ": " + rq_part.

             find pt_mstr where pt_part = rq_part no-lock no-error.
             if available pt_mstr then
            desc1 = desc1 + " " + pt_desc1 + " " + pt_desc2.
          end.

          for each wo_mstr where wo_part = rq_part
          and wo_site = rq_site
          and (wo_due >= rq_start or rq_start = ?)
          and (wo_due <= rq_end or rq_end = ?)
          and (wo_qty_ord - wo_qty_comp - wo_qty_rjct > 0)
          and wo_status <> "C"
/*G0ZB*/          and wo_type <> "C"
          no-lock break by wo_part by wo_nbr:

             if desc1 > "" then do:
            put skip(1) desc1 format "x(100)".
            desc1 = "".
             end.

             /* CALCULATE LOAD INTERVALS FOR A GIVEN WORK ORDER  */
             {mfcload.i}

             display
/*N0K5* {&rprsrp2a_p_11} */
/*N0K5*/     " " + getTermLabel("WORK_ORDER",3) +  ":" format "x(5)"
             wo_nbr format "x(16)" det_load[1 for 12]
             with no-labels width 132 STREAM-IO /*GUI*/ .

             
/*GUI*/ {mfguirex.i } /*Replace mfrpexit*/

          end.
           end.
        end.

        /* DISPLAY LOAD OVER/UNDER AND CUMULATIVE */
        display
/*N0K5* {&rprsrp2a_p_2}  */
/*N0K5*/        getTermLabel("TOTAL_LOAD",14) format "x(14)"
         space(9) load[1 for 12] skip
        with frame d no-labels width 132 STREAM-IO /*GUI*/ .

        do i = 1 to num_intervals:
           assign
              ovund[i] = cap[i] - load[i]
              ovund[i] = integer(ovund[i])
              cum[i] = ovund[i].
           if i > 1 then cum[i] = cum[i] + cum[i - 1].
        end.

/*N0K5* ------------------- BEGIN DELETE ----------------------- *
 *      display {&rprsrp2a_p_7} space(9) ovund[1 for 12] skip
 *      with frame d no-labels width 132.
 *      display {&rprsrp2a_p_3} space(9) cum[1 for 12] skip
 *      with frame d no-labels width 132.
 *N0K5* ------------------- END   DELETE ----------------------- */

/*N0K5* ------------------- BEGIN ADD ----------------------- */
        display
         getTermLabel("OVER/UNDER",14) format "x(14)"
         space(9) ovund[1 for 12] skip
        with frame d no-labels width 132 STREAM-IO /*GUI*/ .

        display
         getTermLabel("CUMULATIVE",14) format "x(14)"
        space(9) cum[1 for 12] skip
        with frame d no-labels width 132 STREAM-IO /*GUI*/ .
/*N0K5* ------------------- END   ADD ----------------------- */
     end.

/*K1DJ*/ {wbrp04.i}
